***Turbull-Dugarte 2020 
*** Cross-pressures and the European lavender vote: Testing the conditionality of the sexuality gap***
***Replication file 1: Main analysis ***


use ESS_analysisfile.dta, clear



rename mnactic empstat
replace empstat=. if empstat>60

replace gincdif=. if gincdif>5
recode gincdif(1=5 "Agree Stongly")(2=4 "Agree")(3=3 "Neither agree/disagree")(4=2 "Disagree")(5=1 "Strongly disagree"), into(incdiff)
gen distribute=.
replace distribute=1 if incdiff>=4
replace distribute=0 if incdiff<4
gen incomenew=income1 if income2==.
replace incomenew=income2 if income2!=.
replace incomenew=. if incomenew>10

gen election=cntryID*year


///IDEOLOGY
logit liberal GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(incomenew=(1(1)10)) post
marginsplot, xlabel(1(1)10) addplot(histogram incomenew if e(sample), discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) leg(pos(6)) )
graph save lib_income_fixed.gph , replace

logit liberal GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(eduyrs=(1(1)25)) post
marginsplot, xlabel(1(1)25) addplot(histogram eduyrs if e(sample) & eduyrs<=25, discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )
graph save lib_ed_fixed.gph , replace


///VOTE CHOICE

**imcome
logit voteleft GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(incomenew=(1(1)10)) post
set scheme plotplain
marginsplot, xlabel(1(1)10) addplot(histogram incomenew if e(sample), discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )
graph save  vc_income_fixed.gph , replace


**eduyears
logit voteleft GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(eduyrs=(1(1)25)) post
marginsplot, xlabel(1(1)25) addplot(histogram eduyrs if e(sample) & eduyrs<=25, discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )
graph save  vc_ed_fixed.gph, replace


///REDISTRIBUTION///
logit distribute GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(incomenew=(1(1)10)) post
marginsplot, xlabel(1(1)10) addplot(histogram incomenew if e(sample), discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )
graph save  dist_income_fixed.gph, replace



logit distribute GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(eduyrs=(1(1)25)) post
marginsplot, xlabel(1(1)25) addplot(histogram eduyrs if e(sample) & eduyrs<=25, discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )
graph save  dist_ed_fixed.gph, replace


graph combine lib_income_fixed.gph lib_ed_fixed.gph vc_income_fixed.gph  vc_ed_fixed.gph dist_income_fixed.gph  dist_ed_fixed.gph




//APPENDIX//

cd "/Users/stuartturnbulldugarte/OneDrive - King's College London/Works in Progress/Pink Vote/PV_conditional/Appendix"



***Income output***
logit liberal GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using incometab2.doc, dec(2) replace
logit voteleft GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.election i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using incometab2.doc, dec(2) append
logit distribute GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.election i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using incometab2.doc, dec(2) append



***Education output***
logit liberal GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using edutab2.doc, dec(2) replace
logit voteleft GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using edutab2.doc, dec(2) append
logit distribute GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.election if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using edutab2.doc, dec(2) append



***Income output with different FE***
logit liberal GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using incometab.doc, dec(2) replace
logit voteleft GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using incometab.doc, dec(2) append
logit distribute GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using incometab.doc, dec(2) append



***Education output with different FE***
logit liberal GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using edutab.doc, dec(2) replace
logit voteleft GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using edutab.doc, dec(2) append
logit distribute GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using edutab.doc, dec(2) append

***EJPR model***

logit liberal GL c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using ejpr.doc, dec(2) replace
logit voteleft GL c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using ejpr.doc, dec(2) append
logit distribute GL c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using ejpr.doc, dec(2) append


***Multilevel modelling***

melogit liberal GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd  i.year if fulldata==1 & partner==1 [pw=weight]|| cntryID:,
outreg2 using incometab_ml.doc, dec(2) replace
melogit voteleft GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.year if fulldata==1 & partner==1 [pw=weight]|| cntryID:,
outreg2 using incometab_ml.doc, dec(2) append
melogit distribute GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd  i.year if fulldata==1 & partner==1 [pw=weight]|| cntryID:,
outreg2 using incometab_ml.doc, dec(2) append


melogit liberal GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight]|| cntryID:,
outreg2 using edutab_ml.doc, dec(2) replace
melogit voteleft GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight]|| cntryID:,
outreg2 using edutab_ml.doc, dec(2) append
melogit distribute GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight]|| cntryID:,
outreg2 using edutab_ml.doc, dec(2) append


***Alternative means of operationsaling education using a categorical indicator***

logit voteleft GL##c.education gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(education=(1(1)5)) post
marginsplot, xlabel(1(1)5) addplot(histogram education if e(sample), discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )

logit liberal GL##c.education gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(education=(1(1)5)) post
marginsplot, xlabel(1(1)5) addplot(histogram education if e(sample), discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )

logit distribute GL##c.education gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(education=(1(1)5)) post
marginsplot, xlabel(1(1)5) addplot(histogram education if e(sample), discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )



***OLS model of ideology***
recode lrscale(0=10 "Left")(1=9)(2=8)(3=7)(4=6)(5=5) (6=4) (7=3) (8=2) (9=1) (10=0 "Right"), into(rile1)

reg rile1 GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(incomenew=(1(1)10)) post
marginsplot, xlabel(1(1)10) addplot(histogram incomenew if e(sample), discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )

reg rile1 GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
margins GL, at(eduyrs=(1(1)25)) post
marginsplot, xlabel(1(1)25) addplot(histogram eduyrs if e(sample) & eduyrs<=25, discrete percent width(1) yaxis(2) yscale(alt) fcolor(%10) lc(black%30) )

reg rile1 GL##c.incomenew gender age c.eduyrs religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using ols_ideology.doc, dec(2) replace
reg rile1 GL##c.eduyrs gender age c.incomenew religious i.domicil econview swd i.cntryID i.year if fulldata==1 & partner==1 [pw=weight], robust cluster(cntry)
outreg2 using ols_ideology.doc, dec(2) append


